package com.longma.server.remote;

import com.longma.server.pojo.UserResponseEntity;
import com.longma.server.pojo.vo.YingshiAddressVO;
import com.longma.server.pojo.vo.YingshiTokenVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 萤石摄像头使用说明
 * http://open.ys7.com/doc/zh/book/index/user.html
 */
@FeignClient(name="yingshi-service",url = "${yingshi.baseUrl}", contextId="YingshiService")
public interface YingshiRemoteService {
    /**
     * 根据appKey和secret获取accessToken
     * 注意：获取到的accessToken有效期是7天，请在即将过期或者接口报错10002时重新获取，每个token具备独立的7天生命周期，请勿频繁调用避免占用过多接口调用次数。
     */
    @PostMapping("/token/get")
    UserResponseEntity<YingshiTokenVO> getAccessToken(@RequestParam String appKey, @RequestParam String appSecret);

    /**
     * 获取播放地址
     * 该接口用于通过设备序列号、通道号获取单台设备的播放地址信息，无法获取永久有效期播放地址
     */
    @PostMapping("/v2/live/address/get")
    UserResponseEntity<YingshiAddressVO> getAddress(@RequestParam String accessToken, @RequestParam String deviceSerial,@RequestParam String validateCode,
                                                    @RequestParam Integer protocol, @RequestParam Integer supportH265);

    /**
     * 添加设备到账号下
     */
    @PostMapping("/device/add")
    UserResponseEntity<String> addDevice(@RequestParam String accessToken,@RequestParam String deviceSerial,@RequestParam String validateCode);

    /**
     * 开始云台控制
     * 对设备进行开始云台控制，开始云台控制之后必须先调用停止云台控制接口才能进行其他操作，包括其他方向的云台转动
     */
    @PostMapping("/device/ptz/start")
    UserResponseEntity<String> startPTZControl(@RequestParam String accessToken,@RequestParam String deviceSerial,@RequestParam Integer direction,@RequestParam Integer speed);

    /**
     * 停止云台控制
     */
    @PostMapping("/device/ptz/stop")
    UserResponseEntity<String> stopPTZControl(@RequestParam String accessToken,@RequestParam String deviceSerial,@RequestParam Integer direction);

    /**
     * 对设备进行镜像翻转操作(需要设备支持)
     */
    @PostMapping("/device/ptz/mirror")
    UserResponseEntity<String> mirrorPTZ(@RequestParam String accessToken,@RequestParam String deviceSerial,@RequestParam Integer channelNo, @RequestParam Integer command);

    /**
     * 根据设备验证码关闭设备视频加密开关
     */
    @PostMapping("/device/encrypt/off")
    UserResponseEntity<String> closeEncrypt(@RequestParam String accessToken,@RequestParam String deviceSerial,@RequestParam String validateCode);

    /**
     * 开启设备视频加密
     */
    @PostMapping("/device/encrypt/on")
    UserResponseEntity<String> openEncrypt(@RequestParam String accessToken,@RequestParam String deviceSerial);
}
